import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/pages/dashboard/index'),
      meta: { title: '首页大屏', icon: 'xingxingdefuben' }
    }]
  },
  {
    path: '/recognition',
    component: Layout,
    children: [{
      path: 'index',
      name: 'recognition',
      component: () => import('@/pages/recognition/index'),
      meta: { title: '图像识别', icon: 'shengdantubiao-05' }
    }]
  },
  {
    path: '/baseuser',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseuser',
        component: () => import('@/pages/BaseUser/baseuser'),
        meta: { title: '用户管理', icon: 'shengdanjie-xingxing' }
      },
      {
        path: 'create',
        hidden:true,
        name: 'baseusercreate',
        component: () => import('@/pages/BaseUser/baseusercreate'),
        meta: { title: '用户创建', icon: 'form' }
      }
    ]
  },
  {
    path: '/baseuserrole',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseuserrole',
        component: () => import('@/pages/BaseUser/baseuserrole'),
        meta: { title: '用户角色', icon: 'shengdanjie-tangguo' }
      },
      {
        path: 'create',
        hidden:true,
        name: 'baseuserrolecreate',
        component: () => import('@/pages/BaseUser/baseuserrolecreate'),
        meta: { title: '角色创建', icon: 'form' }
      }
    ]
  },
  {
    path: '/baseConfig',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseConfig',
        component: () => import('@/pages/lyf/BaseConfig'),
        meta: { title: '配置管理', icon: 'shengdanjie-shoutao' }
      },
      {
        path: 'create',
        hidden: true ,
        name: 'baseConfig_create',
        component: () => import('@/pages/lyf/BaseConfigCreate'),
        meta: { title: '数据字典创建', icon: 'form' }
      }
    ]
  },

{
  path: '/interfaces',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'interfaces',
        component: () => import('@/pages/lyf/Interfaces'),
        meta: { title: '接口管理', icon: 'shengdanjie-shengdanwa' }
      },
      {
        path: 'create',
        hidden: true ,
        name: 'interfaces_create',
        component: () => import('@/pages/lyf/InterfacesCreate'),
        meta: { title: '模型接口创建', icon: 'nested' }
      }
    ]
  },
  {
    path: '/application',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'application',
        component: () => import('@/pages/gyt/Application'),
        meta: { title: '应用模块', icon: 'shengdantubiao-19' }
      },
      {
        path: 'create',
        hidden:true,
        name: 'application_create',
        component: () => import('@/pages/gyt/ApplicationCreate'),
        meta: { title: '应用创建', icon: 'form' }
      }
    ]
  },
  {
    path: '/module',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'module',
        component: () => import('@/pages/gyt/Module'),
        meta: { title: '模块模型', icon: 'shengdanjie-boliqiu' }
      },
      {
        path: 'create',
        hidden:true,
        name: 'module_create',
        component: () => import('@/pages/gyt/ModuleCreate'),
        meta: { title: '模块创建', icon: 'form' }
      }
    ]
  },
  
  {
    path: '/baseFile',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseFile',
        component: () => import('@/pages/lq/baseFile'),
        meta: { title: '数据文件', icon: 'shengdanjie-caideng' }
      },
      {
        path: 'baseFileCreate',
        name: 'baseFileCreate',
        hidden:true,
        component: () => import('@/pages/lq/baseFileCreate'),
        meta: { title: '数据文件'}
      }
    ]
  },
  {
    path: '/datasetFile',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'datasetFile',
        component: () => import('@/pages/lq/datasetFile'),
        meta: { title: '数据集文件', icon: 'shengdanjie-lazhu' }
      },
      {
        path: 'datasetFileCreate',
        name: 'datasetFileCreate',
        hidden:true,
        component: () => import('@/pages/lq/datasetFileCreate'),
        meta: { title: '训练数据'}
      }
    ]
  },
  {
    path: '/dataset',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Dataset',
        component: () => import('@/pages/rl/Dataset'),
        meta: { title: '数据集管理', icon: 'shengdanjie-liwu' }
      },
      {
    path: 'create',
    hidden:true,
    name: 'dataset_create',
    component: () => import('@/pages/rl/DatasetCreated'),
    meta: { title: '数据集创建', icon: 'nested' }
     }
    ]
  },

 
  {
    path: '/counsel',
    component: Layout,
    children: [
    {
        path: 'index',
        name: 'Counsel',
        component: () => import('@/pages/rl/Counsel'),
        meta: { title: '咨询信息', icon: 'shengdanjie-milu' }
      },
      {
        path: 'create',
        hidden:true,
        name: 'counsel_create',
        component: () => import('@/pages/rl/CounselCreated'),
        meta: { title: '咨询信息创建', icon: 'nested' }
         }
        
    ]
  },
  {
    path: '/role',
    component: Layout,
      children: [
        {
          path: 'index',
          name: 'Role',
          component: () => import('@/pages/wyl/Role'),
          meta: { title: '角色', icon: 'shengdanjie-lingdang' }
        },
        {
          path: 'create',
          hidden: true,
          name: 'comment',
          component: () => import('@/pages/wyl/RoleCreated'),
          meta: { title: 'wyl', icon: 'form' }
        }
    ]
  },
  {
    path: '/roleprivilege',
    component: Layout,
      children: [
        {
          path: 'index',
          name: 'RolePrivilege',
          component: () => import('@/pages/wyl/RolePrivilege'),
          meta: { title: '角色权限', icon: 'shengdanjie-boliqiu' }
        },
        {
          path: 'create',
          hidden: true,
          name: 'comment',
          component: () => import('@/pages/wyl/RolePrivilegeCreated'),
          meta: { title: '评论创建', icon: 'form' }
        },

    ]
  },
  {
    path: '/article',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'article',
        component: () => import('@/pages/yg/Article'),
        meta: { title: '文章管理', icon: 'shengdantubiao-05' }
      },
      {
        path: 'create',
        hidden: 'true',
        name: 'article_create',
        component: () => import('@/pages/yg/ArticleCreate'),
        meta: { title: '文章创建', icon: 'nested' }
      }
    ]
  },
  {
    path: '/category',
    component: Layout,

    children: [
      {
        path: 'index',
        name: 'category',
        component: () => import('@/pages/yg/Category'),
        meta: { title: '分类管理', icon: 'shengdanjie-milu' }
      },
      {
        path: 'create',
        hidden: 'true',
        name: 'category_create',
        component: () => import('@/pages/yg/CategoryCreate'),
        meta: { title: '创建类别', icon: 'nested' }
      }
    ]
  },
  
{
    path: '/form',
    path: '/comment',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'comment',
        component: () => import('@/pages/zbq/comment'),
        meta: { title: '评论分析', icon: 'shengdantubiao-02' }
      },
      {
        path: 'create',
        hidden: true,
        name: 'comment',
        component: () => import('@/pages/zbq/commentcreate'),
        meta: { title: '评论创建', icon: 'form' }
      }

    ]
  },
  {
    path: '/greenhouse',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'greenhouse',
        component: () => import('@/pages/zbq/greenhouse'),
        meta: { title: '温室气体', icon: 'shengdanjie-xingxing' }
      },
      {
        path: 'create',
        hidden: true,
        name: 'greenhouse',
        component: () => import('@/pages/zbq/greenhousecreate'),
        meta: { title: '增加', icon: 'form' }
      }
    ]
  },
  {
    path: '/baselog',
    component: Layout,
    children: [
      {
        path: 'baselog',
        name: 'baselog',
        component: () => import('@/pages/lzw/baselog'),
        meta: { title: '日志模块', icon: 'shengdanjie-lingdang' }
      },
      {
        path: 'index',
        hidden:true,
        name: 'baselog',
        component: () => import('@/pages/lzw/baselogcreat'),
        meta: { title: '创建日志', icon: 'shengdanjie-lingdang' }
      }
    ]
  },
  {
    path: '/baseprivilege',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseprivilege',
        component: () => import('@/pages/lzw/baseprivilege'),
        meta: { title: '权限模块', icon: 'shengdanjie-boliqiu' }
      },
      {
        path: 'baseprivileg',
        hidden:true,
        name: 'baseprivilege',
        component: () => import('@/pages/lzw/baseprivilegecreat'),
        meta: { title: '新建权限', icon: 'shengdanjie-boliqiu' }
      }
    ]
  },
  {
    path: '/statistics',
    component: Layout,
    meta:{title:"训练数据",icon: 'shengdanjie-shoutao' },
    children: [
      {
        path: 'test',
        name: 'statistics_test',
        component: () => import('@/pages/statistics/Test'),
        meta: { title: '数据可视化'}
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
